package com.dog.basics.admin.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.HospitalCostAddDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalCostEditDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalCostFromDto;
import com.dog.basics.bean.vo.admin.mtkj.HospitalCostVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceHospitalCostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * <p>
 * 医院费用 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/hospital/cost")
@Api(value = "医院费用模块", tags = "医院费用模块")
@AllArgsConstructor
public class MtDeviceHospitalCostController {
    private final IMtDeviceHospitalCostService mtDeviceHospitalCostService;

    /**
     * @Description: 医院费用列表
     * @Param: HospitalCostFromDto
     * @return: IPage<HospitalCostVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "医院费用列表", notes = "pc:mtDeviceHospitalCost:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalCost:page')")
    public R<IPage<HospitalCostVo>> page(PageParam param,HospitalCostFromDto obj) {
        return R.ok(mtDeviceHospitalCostService.getPageList(param,obj));
    }

    /**
     * @Description: 增加医院费用
     * @Param: HospitalCostAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加医院费用")
    @ApiOperation(value = "增加医院费用", notes = "pc:mtDeviceHospitalCost:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalCost:save')")
    public R<Boolean> save(@Valid @RequestBody HospitalCostAddDto obj) {
        return R.ok(mtDeviceHospitalCostService.saveObj(obj));
    }

    /**
     * @Description: 删除医院费用
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除医院费用")
    @ApiOperation(value = "删除医院费用", notes = "pc:mtDeviceHospitalCost:delete")
    @ApiImplicitParam(value = "医院费用Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalCost:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceHospitalCostService.deleteObj(id));
    }

    /**
     * @Description: 修改医院费用
     * @Param: HospitalCostEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改医院费用")
    @ApiOperation(value = "修改医院费用", notes = "pc:mtDeviceHospitalCost:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalCost:edit')")
    public R<Boolean> edit(@Valid @RequestBody HospitalCostEditDto obj) {
        return R.ok(mtDeviceHospitalCostService.editObj(obj));
    }
}
